<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.CreateExporterTitle}"></h:outputText>
        </ui:define>
      
        <ui:define name="body">
            <!-- Start of the form notifications -->
              <h:panelGroup id="messagePanel" layout="block" >
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"  />
                </h:panelGroup>
            <!-- End of the form Notification -->
 <div class="clear"></div>
            <h:form class="well form-inline">
                <center><h1>اضافة مورد جديد</h1></center>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{bundle.CreateExporterLabel_exporterName}" for="exporterName" />
                    <h:inputText id="exporterName" value="#{exporterController.selected.exporterName}" title="#{bundle.CreateExporterTitle_exporterName}" required="true" requiredMessage="#{bundle.CreateExporterRequiredMessage_exporterName}"/>


                    <h:outputLabel value="#{bundle.CreateExporterLabel_exporterCode}" for="exporterCode" />
                    <h:inputText id="exporterCode" value="#{exporterController.selected.exporterCode}" title="#{bundle.CreateExporterTitle_exporterCode}" required="true" requiredMessage="#{bundle.CreateExporterRequiredMessage_exporterCode}"/>


                    <h:outputLabel value="#{bundle.CreateExporterLabel_phone}" for="phone" />
                    <h:inputText id="phone" value="#{exporterController.selected.phone}" title="#{bundle.CreateExporterTitle_phone}" />


                    <h:outputLabel value="#{bundle.CreateExporterLabel_balance}" for="balance" />
                    <h:inputText id="balance" value="#{exporterController.selected.balance}" title="#{bundle.CreateExporterTitle_balance}" />
 <h:selectBooleanCheckbox value="#{exporterController.boolean1}"/>لينا

                    <h:outputLabel value="#{bundle.CreateExporterLabel_other}" for="other" />
                    <h:inputText id="other" value="#{exporterController.selected.other}" title="#{bundle.CreateExporterTitle_other}" />
                </h:panelGrid>

               
                <div class="clear"></div>
                <div align="center"><h:commandButton  value="اضافه" action="#{exporterController.create}" styleClass="btn btn-primary" /></div>
            </h:form>

            <!-- start of the table -->
            <h:form>
<center><h1>الموردين</h1></center>
                <h:outputText escape="false" value="#{bundle.ListExporterEmpty}" rendered="#{exporterController.items.rowCount == 0}"/>
               
                <h:panelGroup rendered="#{exporterController.items.rowCount > 0}">

                    <p:dataTable  value="#{exporterController.listItems}" var="item" paginator="true" rows="100"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="100,200,300">
                        
                        <p:column filterBy="#{item.exporterCode}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExporterTitle_exporterCode}"/>
                            </f:facet>
                            <h:outputText value="#{item.exporterCode}"/>
                        </p:column>
                        
                        <p:column filterBy="#{item.exporterName}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExporterTitle_exporterName}"/>
                            </f:facet>
                            <h:outputText value="#{item.exporterName}"/>
                        </p:column>
                        
                        <p:column >
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExporterTitle_phone}"/>
                            </f:facet>
                            <h:outputText value="#{item.phone}"/>
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExporterTitle_balance}"/>
                            </f:facet>
                            <h:panelGroup rendered="#{(item.balance eq 0)}">

                                  #{(item.balance)}

                                    </h:panelGroup>
                             <h:panelGroup rendered="#{(item.balance lt 0)}">
                                
                                  #{(item.balance)*-1 }
                               
                                    </h:panelGroup>
                                 <h:panelGroup rendered="#{item.balance > 0}" >
                                   
                                    #{item.balance}
                                    لينا
                                    </h:panelGroup>
                        </p:column>
                        
                        <p:column >
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExporterTitle_other}"/>
                            </f:facet>
                            <h:outputText value="#{item.other}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{exporterController.prepareView(item)}" value="#{bundle.ListExporterViewLink}" class="btn btn-primary"/>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{exporterController.prepareEdit(item)}" value="#{bundle.ListExporterEditLink}" class="btn btn-primary"/>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{exporterController.destroy(item)}" value="#{bundle.ListExporterDestroyLink}" class="btn btn-primary"/>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{exporterController.bills(item)}" value="#{bundle.getBills}" class="btn btn-primary"/>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
            </h:form>
            <!-- end of the table -->
          
            
            <div class="clear"></div>
            <button style="margin-right: 500px;" class="btn btn-primary" type="button">اطبع</button>
            <!-- end of the container -->
            
        </ui:define>
    </ui:composition>>
</html>

